﻿using LoveEat.API.Read.Applications.Commands.Paths;
using LoveEat.Domain;
using LoveEat.ErrorCode;
using LoveEat.Infrastructure.Interfaces;
using MediatR;

namespace LoveEat.API.Read.Applications.CommandHandlers.Paths
{
    public class PathQueryCommandHandler : IRequestHandler<PathQueryCommand, APIResult<List<PathModel>>>
    {
        private readonly IBaseRespository<PathModel> pathRep;

        public PathQueryCommandHandler(IBaseRespository<PathModel> pathRep)
        {
            this.pathRep = pathRep;
        }

        public Task<APIResult<List<PathModel>>> Handle(PathQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<PathModel>> result = new APIResult<List<PathModel>>();
            result.Code=APIResultCode.查询成功;
            result.Message=APIResultCode.查询成功.ToString();

            var res=pathRep.GetAll().ToList();
            result.Data = res;


            return Task.FromResult(result);
        }
    }
}
